$(document).ready(function(){

	$('.carousel').carousel();
    $('.list > li').mouseover(function(){
    	$(this).addClass("active-add");
    	//$(this).css({"background-color":"#669acc","color":"white"});
    	//$(".text span").css({"color":"yellow"});
    }).mouseout(function(){
    	$(this).removeClass("active-add");
    	//$(this).css({"background-color":"white","color":"#669acc"});
    	//$(".text span").css({"color":"#669acc"});
    });
    $("#login").popover({
    	html:'true',
    	content:"<form id='login_form'><div id = 'login_first_match'><span class = 'icon_login' id = 'icon_account'>@</span><input type = 'text' placeholder='邮箱/手机号'></div><div><span class = 'icon_login' id = 'icon_password'>x</span><input type = 'password' placeholder='密码'></div><label class ='checkbox'><input type = 'checkbox'>记住密码</label><button type = 'submit' class = 'btn'>登录</button><a href='#''>还没有账号？立刻注册</a></form>"
    });
    $("#login").popover('hide');
    Cuntdown_textarea();

    $('#send_comments').click(function(){
        if($('#comments-content')[0].value == ""){
            //$('#comments-content').css.fadeIn(200).fadeOut(200).fadeIn(200).fadeOut(200);
            return;
        }
        else
        {
            $('#send_comments')[0].disabled=true; //发布成功后，禁止 
            var timer = new Date();
            /*------静态添加看效果---------*/

            $('<div class="comment"><span class="imgOut"><img src="../../static/images/head-1.jpg" class="head-imgs" width ="50" height = "50"/></span><div class = "comment-author">我是用户:</div><div class="comment-text"></div><div class="time-info">'+"&emsp;("+(timer.getMonth()+1)+"月"+timer.getDate()+"日"+"&ensp;"+timer.getHours()+":"+timer.getMinutes()+")"+'</div><a class = "reply pull-right" href = "#">回复</a><hr></div>').prependTo($('#comments'));
            $('.comment-text')[0].innerText=$('#comments-content')[0].value;
            //清空 
            $('#comments-content')[0].value="";
            $('.comment:first').hide().slideDown("slow");

            $('#send_comments')[0].disabled=false;

            /*-----------------------------*/
        /*
            $.get("details.php",{
                     username:'用户',
                     content: $('#comments-content').val()
            },function(data,textStatus){
                     var username = data.username;
                     var content = data.content;
                     
                     $('<div class="test"><span class="imgOut"><img src="images/wukong.gif" class="imgs"/></span><div class="con"></div><div class="inf">'+timer.getHours()+"时"+timer.getMinutes()+"分"+timer.getSeconds()+"秒"+'<input type="button" value="删除" class="bu"/></div></div>').prependTo($('#comments'));
             },"json");
        */
        }

    });

    $("#head-image").popover({
        html:'true',
        content:"<ul id = 'user-items'><li><a href = '#'>个人信息</a></li><li><a href = '#'>我创建的</a></li><li><a href = '#'>我参与的</a></li></ul>"
    });
    $("head-image").popover('hide');


});



function Cuntdown_textarea(){
    $(".modal-body textarea").keydown(function(){
        var curLength=$(this).val().length;
        if(curLength>=141){
            var num=$(this).val().substr(0,140);
            $(this).val(num);
            alert("你的介绍过长了哦~");
        }
        else{

            $(".modal-body span").text(140-$(this).val().length);

        }

    })

}


